package com.gxy.learn.backup.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * Environment 方式读取
 */
@Slf4j
@Data
@Component
public class EnvironmentConfig {
    @Autowired
    private Environment environment;

    private String userName;
    private Integer sex;
    private Integer age;

    @PostConstruct
    public void init() {
        String userName = environment.getProperty("com.gxy.learn.am.user.userName");
        Integer sex = environment.getProperty("com.gxy.learn.am.user.sex",Integer.TYPE);
        Integer age = environment.getProperty("com.gxy.learn.am.user.age",Integer.TYPE);
        this.userName = userName;
        this.sex = sex;
        this.age = age;
    }
}
